<template>
    <div>
        <Button v-if="showBackBtn" class="goBack" type="primary" @click="$router.back()">
            <Icon type="ios-arrow-back"/>
            返回
        </Button>
        <Form ref="formCustom" :model="formCustom"   :rules="ruleCustom" :label-width="150">
            <h3>项目基本情况</h3>
            <Card class="line-style">
                <div class="line-wrap">
                    <div class="line-main">
                        <Row>
                            <Col span="7">
                                <Form-item label="项目名称" prop="xmmc">
                                    <i-input type="text" v-model="formCustom.xmmc" placeholder="请输入项目名称"></i-input>
                                </Form-item>
                            </Col>
                            <Col span="7">
                                <Form-item label="发改委投资计划文号">
                                    <i-input type="text" v-model="formCustom.fgwtzjhwh" placeholder="请输入发改委投资计划文号"></i-input>
                                </Form-item>
                            </Col>
                            <Col span="7">
                                <Form-item label="拦标价金额" prop="lbjje">
                                    <i-input type="number" number v-model="formCustom.lbjje" placeholder="请输入拦标价金额"><span slot="append">万元</span></i-input>
                                </Form-item>
                            </Col>
                        </Row>
                        <Row>
                            <Col span="7">
                                <Form-item label="实际投资额" prop="sjtze">
                                    <i-input type="number" number v-model="formCustom.sjtze" placeholder="请输入实际投资额"><span slot="append">万元</span></i-input>
                                </Form-item>
                            </Col>
                            <Col span="7">
                                <Form-item label="计划资金" prop="jhzj">
                                    <i-input type="number" number v-model="formCustom.jhzj" placeholder="请输入计划资金"><span slot="append">万元</span></i-input>
                                </Form-item>
                            </Col>
                            <Col span="7">
                                <Form-item label="投资计划下达时间">
                                    <DatePicker @on-change="startChange($event,1)"
                                                format="yyyy-MM-dd" :value="formCustom.jhxdsj"
                                                type="date" placeholder="选择投资计划下达时间"></DatePicker>
                                </Form-item>
                            </Col>
                            <Col span="7">
                                <Form-item label="预算年度">
                                    <i-input type="text" v-model="formCustom.ysnd" placeholder="请输入预算年度"></i-input>
                                </Form-item>
                            </Col>
                        </Row>
                        <!--<Row>
                            <Col>
                                <Form-item label="建设单位" prop="jsdw">
                                    &lt;!&ndash;<Select  style="width:100%" v-model="formCustom.jsdw"
                                                 placeholder="请选择建设单位">
                                            <Option v-for="item in syTypeList" :key="item.value" :value="item.value">{{item.label}}</Option>
                                        </Select>&ndash;&gt;
                                    <Cascader :data="jsdwList" v-model="formCustom.jsdw" change-on-select placeholder="请选择建设单位"></Cascader>
                                </Form-item>
                            </Col>
                            &lt;!&ndash;<Col span="7">
                                <Form-item label="上报日期" prop="sbrq">
                                    <DatePicker @on-change="dateChange" :options="options1" :value="formCustom.sbrq"
                                                format="yyyy-MM-dd"
                                                type="date" placeholder="选择上报日期"></DatePicker>
                                </Form-item>
                            </Col>&ndash;&gt;
                        </Row>-->
                        <Row>
                            <Col>
                                <Form-item label="项目简单概述" prop="xmjdgs">
                                    <i-input type="textarea" v-model="formCustom.xmjdgs" :rows="5"
                                             placeholder="请输入项目简单概述(100字以内)" maxlength="100" show-word-limit></i-input>
                                </Form-item>
                            </Col>
                        </Row>
                    </div>
                </div>
            </Card>

            <h3>招标情况</h3>
            <Card class="line-style">
                <div class="line-wrap">
                    <div class="line-main">
                        <Row>
                            <Col span="7">
                                <Form-item label="招标项目编号" prop="zbxmbh">
                                    <i-input type="text" v-model="formCustom.zbxmbh" placeholder="请输入招标项目编号"></i-input>
                                </Form-item>
                            </Col>

                        </Row>
                        <div v-for="(item,index) in formCustom.bz_info" :key="index" class="tenderDiv">
                            <Row >
                                <Col span="7">
                                    <Form-item label="包组名称" :prop="`bz_info[${index}].bzname`" :rules="[{ required: true, message: '包组名称必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="item.bzname" placeholder="请输入包组名称"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="招标单位/采购单位" :prop="`bz_info[${index}].cgdwmc`" :rules="[{ required: true, message: '招标单位/采购单位必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="item.cgdwmc" placeholder="请输入招标单位/采购单位"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <!--<Form-item label="中标单位名称" :prop="`bz_info[${index}].zbdwmc`" :rules="[{ required: true,type:'array', message: '请输入中标单位名称', trigger: 'change' }]">
                                        <Cascader :data="jsdwList" v-model="item.zbdwmc" change-on-select placeholder="请选择中标单位"></Cascader>
                                    </Form-item>-->
                                    <Form-item label="中标单位名称" :prop="`bz_info[${index}].zbdwmc`" :rules="[{ required: true, message: '中标单位名称必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="item.zbdwmc" placeholder="请输入中标单位名称"></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="7">
                                    <Form-item label="甲方法人">
                                        <i-input type="text" v-model="item.jffr" placeholder="请输入甲方法人"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="甲方经办人">
                                        <i-input type="text" v-model="item.jfjbr" placeholder="请输入甲方经办人"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="手机号">
                                        <i-input type="text"  v-model="item.jfsjh" placeholder="请输入手机号"></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="7">
                                    <Form-item label="乙方法人">
                                        <i-input type="text" v-model="item.yffr" placeholder="请输入乙方法人"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="乙方经办人">
                                        <i-input type="text" v-model="item.yfjbr" placeholder="请输入乙方经办人"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="手机号">
                                        <i-input type="text"  v-model="item.yfsjh" placeholder="请输入手机号"></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col>
                                    <Form-item label="包组内容" :prop="`bz_info[${index}].bznr`" :rules="[{ required: true, message: '包组内容必填', trigger: 'blur' }]">
                                        <i-input type="textarea" v-model="item.bznr"
                                                 placeholder="请输入包组内容(100字以内)" maxlength="100" show-word-limit></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="7">
                                    <Form-item label="中标金额" :prop="`bz_info[${index}].zbje`" :rules="[{ required: true, type: 'number',message: '中标金额必填', trigger: 'blur' },{ validator: validateFloat, trigger: 'blur' }]">
                                        <i-input type="number" number v-model="item.zbje" placeholder="请输入中标金额"><span slot="append">万元</span></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="合同签订日期" >
                                        <DatePicker @on-change="handleChange($event,item)"
                                                    format="yyyy-MM" :value="item.htqdrq"
                                                    type="month" placeholder="请选择合同签订日期"></DatePicker>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row style="text-align: center">
                                <Col v-if="!showDetail">
                                    &nbsp;&nbsp;<Button type="success" @click="addLine()">添加包组</Button>&nbsp;&nbsp;
                                    <Button type="error" @click="delLine(index)">删除包组</Button>
                                </Col>
                            </Row>
                        </div>
                    </div>
                </div>
            </Card>

            <h3>项目主要包括基本内容</h3>
            <Card class="line-style">
                <div class="line-wrap">
                    <div class="line-main">
                        <Row>
                            <Col span="6">
                                <Form-item label="项目性质">
                                    <RadioGroup v-model="formCustom.xm_info.xmxz" @on-change="clearValidate">
                                        <Radio v-for="(item,index) in xmnrTypeList" :key="index" :label="item.codemc" :value="item.code">
                                            {{item.codemc}}
                                        </Radio>
                                    </RadioGroup>
                                </Form-item>
                            </Col>
                        </Row>
                        <div v-if="formCustom.xm_info.xmxz ==='信息系统' ">
                            <!--信息系统-->
                            <Row>
                                <Col span="7">
                                    <Form-item label="系统名称" :prop="`xm_info.xtmc`" :rules="[{ required: true, message: '系统名称必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.xtmc" placeholder="请输入系统名称"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="IP地址" :prop="`xm_info.ip`" :rules="[{ required: true, message: 'IP地址必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.ip" placeholder="请输入IP地址"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="域名" :prop="`xm_info.ym`">
                                        <i-input type="text" v-model="formCustom.xm_info.ym" placeholder="请输入域名"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="用户名" :prop="`xm_info.yhm`" :rules="[{ required: true, message: '用户名必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.yhm" placeholder="请输入用户名"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="7">
                                    <Form-item label="密码" :prop="`xm_info.mm`" :rules="[{ required: true, message: '密码必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.mm" placeholder="请输入密码"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="9">
                                    <Form-item label="服务器存放物理地址" :prop="`xm_info.fwqcfdz`" :rules="[{ required: true,type: 'array', message: '服务器存放物理地址必选', trigger: 'change' }]">
                                        <Select  style="width:100%" multiple  v-model="formCustom.xm_info.fwqcfdz"
                                                 placeholder="请选择服务器存放物理地址">
                                            <Option v-for="(item,index) in fuqcfTypeList" :key="index" :value="item.codemc" >
                                                {{item.codemc}}
                                            </Option>
                                        </Select>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="8">
                                    <Form-item label="网络情况" :prop="`xm_info.wlqk`" :rules="[{ required: true, message: '网络情况必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.wlqk">
                                            <Radio v-for="(item,index) in wlTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                                <Col span="10">
                                    <Form-item label="使用状况" :prop="`xm_info.syzk`" :rules="[{ required: true, message: '使用状况必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.syzk">
                                            <Radio v-for="(item,index) in syTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                                <Col span="5">
                                    <Form-item label="绩效评价" :prop="`xm_info.jxpj`" :rules="[{ required: true, message: '绩效评价必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.jxpj">
                                            <Radio v-for="(item,index) in jxTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="8">
                                    <Form-item label="等级保护情况" :prop="`xm_info.djbhqk`" :rules="[{ required: true, message: '等级保护情况必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.djbhqk">
                                            <Radio v-for="(item,index) in djbhTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                                <Col span="10" v-if="formCustom.xm_info.djbhqk === '已备案'">
                                    <Form-item label="备案等级" :prop="`xm_info.djbadj`" :rules="[{ required: true, message: '备案等级必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.djbadj" placeholder="请输入备案等级"></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                            <Row>
                                <Col span="8">
                                    <Form-item label="分级保护情况" :prop="`xm_info.fjbhqk`" :rules="[{ required: true, message: '分级保护情况必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.fjbhqk">
                                            <Radio v-for="(item,index) in fjbhTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                                <Col span="10" v-if="formCustom.xm_info.fjbhqk === '已备案'">
                                    <Form-item label="备案等级" :prop="`xm_info.fjbadj`" :rules="[{ required: true, message: '备案等级必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.fjbadj" placeholder="请输入备案等级"></i-input>
                                    </Form-item>
                                </Col>
                            </Row>
                        </div>
                        <div  v-if="formCustom.xm_info.xmxz==='硬件' ">
                            <!--硬件-->
                            <Row>
                                <Col span="8">
                                    <Form-item label="存放地址" :prop="`xm_info.cfdz`" :rules="[{ required: true, message: '存放地址必填', trigger: 'blur' }]">
                                        <i-input type="text" v-model="formCustom.xm_info.cfdz" placeholder="请输入存放地址"></i-input>
                                    </Form-item>
                                </Col>
                                <Col span="10">
                                    <Form-item label="使用状况" :prop="`xm_info.yjsyzk`" :rules="[{ required: true, message: '使用状况必选', trigger: 'change' }]">
                                        <RadioGroup v-model="formCustom.xm_info.yjsyzk">
                                            <Radio v-for="(item,index) in syTypeList" :key="index" :label="item.codemc" :value="item.code">
                                                {{item.codemc}}
                                            </Radio>
                                        </RadioGroup>
                                    </Form-item>
                                </Col>
                            </Row>
                        </div>
                    </div>
                </div>
            </Card>

        </Form>
        <Row justify="center" type="flex" style="margin-top: 10px" v-if="!showDetail">
            <Col>
                <Button type="primary" @click="validateForm('formCustom')">保存</Button>
            </Col>
        </Row>

        <Modal
                v-model="modal"
                title="确认操作"
                width="20"
                @on-ok="handleSubmit"
        >
            <div style="text-align:center">
                <p>是否确认保存!</p>
            </div>
        </Modal>

    </div>
</template>

<script>
import { insert, getById, getDictInfoList, getJsdwList } from '@/api/outbreak-management/government-Informationization-project/government-project'

/*
    信息化---政务信息化项目情况添加
     */
export default {
  data () {
    const validateFloat = (rule, value, callback) => {
      if (value) {
        const reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/
        if (!reg.test(value)) {
          callback(new Error('最多只允许两位小数'))
        } else {
          callback()
        }
      } else {
        callback()
      }
    }
    return {
      validateFloat: (rule, value, callback) => {
        const reg = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/
        if (!reg.test(value)) {
          callback(new Error('最多只允许两位小数'))
        } else {
          callback()
        }
      },
      options1: { // 不可选今天之后的日期
        disabledDate (date) {
          return date && date.valueOf() > Date.now()
        }
      },
      // 弹窗控制
      modal: false,
      // 控制保存按钮显隐
      showDetail: false,
      // 控制返回按钮显隐
      showBackBtn: false,
      formCustom: {
        xmmc: '',
        // jsdw: [], // 建设单位
        fgwtzjhwh: '', // 发改委投资计划文号
        jhzj: '', // 计划资金
        jhxdsj: '', // 计划下达时间
        ysnd: '', // 预算年度
        lbjje: '', // 拦标价金额
        sjtze: '', // 实际投资额
        xmjdgs: '', // 项目简单概述
        zbxmbh: '', // 项目招标编号
        // type: '0', // 类型---0=更改  1=提报
        // 包组信息
        bz_info: [{
          bzname: '',
          bznr: '',
          zbdwmc: '', // 中标单位名称
          // zbdwmc: [], // 中标单位名称
          cgdwmc: '', // 招标单位/采购单位
          zbje: '', // 中标金额
          jffr: '', // 甲方法人
          jfjbr: '', // 甲方经办人
          jfsjh: '', // 手机号
          yffr: '', // 乙方法人
          yfjbr: '', // 乙方经办人
          yfsjh: '', // 手机号
          htqdrq: ''// 合同签订日期
        }],
        // 项目信息
        xm_info: {
          xmxz: '信息系统', // 项目性质--信息系统/硬件
          xtmc: '', // 系统名称
          ym: '', // 域名
          ip: '', // ip地址
          yhm: '', // 用户名
          mm: '', // 密码
          wlqk: '', // 网络情况
          fwqcfdz: '', // 服务器存放地址
          syzk: '', // 使用状况
          djbhqk: '', // 等级保护情况
          djbadj: '', // 备案等级
          fjbhqk: '', // 分级保护情况
          fjbadj: '', // 备案等级
          jxpj: '', // 绩效评价
          // 硬件
          cfdz: '', // 存放地址
          yjsyzk: ''// 使用状况
        }
        // sbrq: ''// 上报时间
      },
      xmnrTypeList: [], // 项目类型字典
      wlTypeList: [], // 网络情况字典
      fuqcfTypeList: [], // 服务器存放物理地址字典
      syTypeList: [], // 使用情况字典
      djbhTypeList: [], // 等级保护情况字典
      fjbhTypeList: [], // 分级保护情况字典
      jxTypeList: [], // 绩效评价字典
      jsdwList: [], // 建设单位字典
      // 集中安置点--显隐
      isShowJzazd: true,
      // 是否隔离
      isOlate: true,
      // 是否核酸检测
      isNad: true,
      ruleCustom: {
        xmmc: [
          { required: true, message: '项目名称必填', trigger: 'blur' },
          { min: 0, max: 30, message: '项目名称长度不能超过30', trigger: 'blur' }
        ],
        // jsdw: [{ required: true, type: 'array', message: '建设单位必选', trigger: 'change' }], // 建设单位
        // jhxdsj: [{ required: true, message: '投资计划下达时间必选', trigger: 'blur' }],
        xmjdgs: [
          { required: true, message: '项目简单概述必填', trigger: 'blur' },
          { min: 0, max: 100, message: '项目简单概述长度不能超过100', trigger: 'blur' }
        ],
        // sbrq: [{ required: true, message: '上报日期必选', trigger: 'blur' }],
        jhzj: [{ required: false, validator: validateFloat, trigger: 'blur' }], // 计划资金
        lbjje: [{ required: false, validator: validateFloat, trigger: 'blur' }], // 拦标价金额
        sjtze: [
          { required: true, type: 'number', message: '实际投资额必填', trigger: 'blur' },
          { validator: validateFloat, trigger: 'blur' }
        ], // 实际投资额
        zbxmbh: [{ required: true, message: '招标项目编号必填', trigger: 'blur' }]
      }
    }
  },
  methods: {
    clearValidate () {
      this.$nextTick(() => {
        let formData = JSON.stringify(this.formCustom)
        this.$refs.formCustom.resetFields()
        this.formCustom = JSON.parse(formData)
      })
    },
    validateForm (name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.modal = true
        } else {
          this.$Message.error('表单验证失败,请检查后再试!')
        }
      })
    },

    /**
             * 日期格式化
             */
    dateChange (date) {
      this.formCustom.sbrq = date
    },
    /**
             * 日期格式化
             */
    startChange (date, index) {
      if (index === 1) {
        this.formCustom.jhxdsj = date
      }
    },
    handleChange  (date, item) {
      item.htqdrq = date
    },
    handleSubmit () {
      let requestData = { ...this.formCustom }
      // 判断有空值的都设置成'无'--start
      for (let item in requestData) {
        if (item === 'fgwtzjhwh' && (requestData[item] === '' || requestData[item] == null)) {
          requestData[item] = '无'
        }
        if (item === 'bz_info') {
          let bzArr = requestData[item]
          bzArr.forEach(ii => {
            for (let sx in ii) {
              if (sx !== 'bzname' && sx !== 'bznr' && sx !== 'zbdwmc' && sx !== 'zbje' && sx !== 'htqdrq') {
                if (ii[sx] === '' || ii[sx] == null) {
                  ii[sx] = '无'
                }
              }
            }
          })
        } else if (item === 'xm_info') {
          let xmObj = requestData[item]
          for (let xmsx in xmObj) {
            if (xmsx === 'ym' && (xmObj[xmsx] === '' || xmObj[xmsx] == null)) {
              xmObj[xmsx] = '无'
            }
          }
        }
      }
      // end
      if (requestData.id) {
        requestData.type = '0'// 修改
      }
      requestData.bz_info = JSON.stringify(requestData.bz_info)
      // requestData.jsdw = JSON.stringify(requestData.jsdw)
      let myArray = new Array(requestData.xm_info)
      requestData.xm_info = JSON.stringify(myArray)
      insert(requestData).then(({ data }) => {
        let { errcode } = data
        if (errcode === 0) {
          this.$Message.success('保存成功!')
        } else {
          this.$Message.error('保存失败!')
        }
      })
    },
    isEditStatus () {
      if (this.$route.query && this.$route.query.id) {
        if (this.$route.query.showDetail) {
          this.showDetail = true
        }
        this.showBackBtn = true
        this.getEditData(this.$route.query.id)
      }
    },
    getEditData (id) {
      let now_xm = this.formCustom.xm_info
      let now_bz = this.formCustom.bz_info
      // let now_jsdw = this.formCustom.jsdw
      getById({ id }).then(({ data }) => {
        let { errcode, data: res } = data
        if (errcode === 0) {
          this.formCustom = res
          this.formCustom.sjtze = Number(res.sjtze)
          this.formCustom.jhxdsj = (res.jhxdsj === '' || res.jhxdsj == null ? null : this.$common.moment(res.jhxdsj).format('YYYY-MM-DD'))
          // this.formCustom.sbrq = (res.sbrq === '' || res.sbrq == null ? null : this.$common.moment(res.sbrq).format('YYYY-MM-DD'))
          this.formCustom.bz_info = res.hasOwnProperty('bz_info') ? JSON.parse(res.bz_info) : now_bz
          // this.formCustom.jsdw = res.hasOwnProperty('jsdw') ? JSON.parse(res.jsdw) : now_jsdw
          // 格式化日期
          this.formCustom.bz_info.forEach(function (item, idnex, array) {
            if (item.hasOwnProperty('htqdrq')) {
              // item.htqdrq = (item.htqdrq === '' || item.htqdrq == null ? null : this.$common.moment(item.htqdrq).format('YYYY-MM-DD'))
            }
          })
          // let arr_xm = new Array(res.xm_info)
          this.formCustom.xm_info = res.hasOwnProperty('xm_info') ? JSON.parse(res.xm_info)[0] : now_xm
          console.info(this.formCustom)
        }
      })
    },
    // 调用字典方法
    queryDictInfo (type) {
      getDictInfoList({ type: type }).then(({ data }) => {
        let { errcode, data: res } = data
        if (errcode === 0 && res.length > 0) {
          let formList = []
          res.forEach(item => {
            let { codemc, code } = item
            let formObj = { codemc: codemc, code: code }
            formList.push(formObj)
          })
          if (type === 'xmnr_type') {
            // 项目类型
            this.xmnrTypeList = formList
          }
          if (type === 'wl_type') {
            // 网络情况
            this.wlTypeList = formList
          }
          if (type === 'fuqcf_type') {
            // 服务器存放物理地址
            this.fuqcfTypeList = formList
          }
          if (type === 'sy_type') {
            // 使用状况
            this.syTypeList = formList
          }
          if (type === 'djbh_type') {
            // 等级保护
            this.djbhTypeList = formList
          }
          if (type === 'fjbh_type') {
            // 分级保护
            this.fjbhTypeList = formList
          }
          if (type === 'jx_type') {
            // 绩效评价
            this.jxTypeList = formList
          }
        }
      })
    },
    // 调用字典方法--建设单位
    queryJsdwList () {
      getJsdwList().then(({ data }) => {
        let { errcode, data: res } = data
        if (errcode === 0 && res.length > 0) {
          let formList = []
          res.forEach(item => {
            if (item.yjpid === '0') {
              formList.push({ value: item.yidw, label: item.yidw, id: item.yjpid })
            } else {
              getJsdwList({ yjpid: item.yjpid }).then(({ data }) => {
                formList.push({ value: item.yidw, label: item.yidw, id: item.yjpid, children: data.data, loading: false })
              })
            }
          })
          this.jsdwList = formList
        }
      })
    },
    addLine () {
      this.formCustom.bz_info.push(
        {
          bzname: '',
          bznr: '',
          zbdwmc: '', // 中标单位名称
          // zbdwmc: [], // 中标单位名称
          cgdwmc: '', // 招标单位/采购单位
          zbje: '', // 中标金额
          jffr: '', // 甲方法人
          jfjbr: '', // 甲方经办人
          jfsjh: '', // 手机号
          yffr: '', // 乙方法人
          yfjbr: '', // 乙方经办人
          yfsjh: '', // 手机号
          htqdrq: ''// 合同签订日期
        })
    },
    delLine (index) {
      let len = this.formCustom.bz_info.length
      if (len === 1) {
        this.$Message.warning('只有一条数据不允许删除!')
        return
      }
      this.formCustom.bz_info.splice(index, 1)
      this.clearValidate()
    }
  },
  created () {
    // this.queryJsdwList() // 建设单位字典
    this.queryDictInfo('xmnr_type') // 项目类型
    this.queryDictInfo('wl_type') // 网络情况
    this.queryDictInfo('fuqcf_type') // 服务器存放物理地址
    this.queryDictInfo('sy_type') // 使用状况
    this.queryDictInfo('djbh_type') // 等级保护情况
    this.queryDictInfo('fjbh_type') // 分级保护情况
    this.queryDictInfo('jx_type') // 绩效评价
    this.isEditStatus()
  },
  mounted () {
  }
}
</script>

<style scoped>
    h3{
        margin: 10px auto;
    }
    .tenderDiv{
        border:solid 1px #dcdee2;
        margin: 4px 4px;
        padding: 4px
    }
</style>
